////////#include<iostream>
////////using namespace std;
////////int main()
////////{
////////	const int N =  200;
////////	double a[N];
////////	double sum = 0;
////////	int n, m;cin >> n >> m;double ret = 0;
////////	for (int i = 1; i <= m; i++)
////////	{
////////		cin >> a[i];
////////		sum += a[i];
////////		ret = max(ret, a[i]);
////////	}
////////	double u = sum / m;int count = 0;
////////	for (int i = 1; i <= m; i++)
////////	{
////////		if (a[i] > u && a[i] != u)
////////			count++;
////////	
////////	}
////////	printf("%.2lf ", ret);
////////	cout << count;
////////	return 0;
////////}
//////#include<iostream>
//////using namespace std;
//////int main()
//////{
//////	double a[200];
//////	int t, n;cin >> t >> n;
//////	double sum = 0;double ret = 0;
//////	for (int i = 1; i <= n; i++)
//////	{
//////		cin >> a[i];
//////		sum += a[i];
//////		ret = max(ret, a[i]);
//////	}
//////	double u =1.0 * t / n;int count = 0;
//////	for (int i = 1; i <= n; i++)
//////	{
//////		if (a[i] > u) count++;
//////	}
//////	printf("%.2lf ", ret);
//////	cout << count;
//////	return 0;
//////}
//////#include<iostream>
//////using namespace std;
//////typedef long long ll;
//////int main()
//////{
//////	ll a[20];double sum = 0;ll ret = 0, ans = 1e9;
//////	for (int i = 1; i <= 10; i++)
//////	{
//////		cin >> a[i];
//////		ret = max(ret, a[i]);
//////		ans = min(ans, a[i]);
//////		sum += a[i];
//////	}
//////	printf("%.1lf ", sum / 10);
//////	cout << ans << ' ' << ret;
//////
//////	return 0;
//////}
////#define _CRT_SECURE_NO_WARNINGS
////#include<stdio.h>
////int main()
////{
////	int a[20];double sum = 0;int ret = -1e9, ans = 1e9;
////	for (int i = 1; i <= 10; i ++ )
////	{
////		scanf("%d", &a[i]);
////		sum += (double)a[i];
////		if (a[i] > ret) ret = a[i];
////		if (a[i] < ans) ans = a[i];
////	}
////	printf("%.1lf %d %d", sum / 10,ans,ret);
////	return 0;
////}
//#include<iostream>
//#include<algorithm>
//using namespace std;
//int main()
//{
//	int a[90];
//	int n;cin >> n;
//	for (int i = 1; i <= n; i++)
//	{
//		cin >> a[i];
//	}
//	int x;cin >> x;int left = 1;
//	for (int i = 1; i <= n;i++)
//	{
//		if (a[i] == x)
//		{
//			a[i] = -1;
//			break;
//		}
//	}
//	for (int i = 1; i <= n; i++)
//	{
//		if (a[i] == -1)continue;
//		cout << a[i] << ' ';
//	}
//	cout << endl;
//	return 0;
//}
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a[2000];
	int n;cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	int y, b;cin >> y>> b;
	for (int i = 1; i <= n; i++)
	{
		if (a[i] == y) a[i] = b;
		cout << a[i] << ' ';
	}
	return 0;
}